#include <iostream>
#include <algorithm>
int data[]{1, 2, 3, 4, 5, 6, 7, 8, 9};
int main()
{
    int count = 0;
    do
        count += (data[0] + data[3]) * 100 + (data[1] + data[4]) * 10 + data[2] + data[5] == data[6] * 100 + data[7] * 10 + data[8];
    while (std::next_permutation(data, data + 9));
    std::cout << count;
}
